package bat.iog.hytool;

public class FileUtils {

    /**
     * 获取文件后缀
     * @param fileName
     * @return
     */
    public static String getFileExt(String fileName) {
        if (fileName == null)
            return "";

        String ext = "";
        int lastIndex = fileName.lastIndexOf(46);//. 46
        if (lastIndex >= 0) {
            ext = fileName.substring(lastIndex + 1).toLowerCase();
        }

        return ext;
    }
    
    /**
     * 得到不包含后缀的文件名字
     * @return
     */
    public static String getRealName(String name) {
        if (name == null) {
            return "";
        }

        int endIndex = name.lastIndexOf(46);
        if (endIndex == -1) {
            return null;
        }
        return name.substring(0, endIndex);
    }
}
